#-------------------------------------------------------------------------------
# Name:        模块1
# Purpose:
#
# Author:      sy
#
# Created:
# Copyright:   (c) sy
# Licence:     <your licence>
#-------------------------------------------------------------------------------
#  这是 mtk 项目的camera
import uiautomator2 as u2
import time
##import sys


with open("and_sn.txt", "r") as f:
    and_sn = f.readline()
    print(and_sn)

d = u2.connect("{}".format(and_sn))
if __name__ == '__main__':
    d = u2.connect()


## 输入文本
##d.send_keys("11", clear=True)
##d(resourceId="android:id/title", text="Connected devices").click()
##d(resourceId="android:id/title", text="Connection preferences").click()
##d(resourceId="android:id/title", text="Bluetooth").click()
##d(resourceId="android:id/title", text="Pair new device").click()

f.close()
class bluetooth_1():
##    def devices_connect(*args):
##        d = u2.connect("{}".format(args))

    #启动camera
    def start_app_1():

        d.app_stop("com.android.settings")
        time.sleep(3)
        d.app_start("com.android.settings")
        print("进入setting")
        time.sleep(3)
    def advance_to_bluetooth():
        time.sleep(2)
        print("点击Connected devices")
        d(resourceId="android:id/title", text="Connected devices").click()
        time.sleep(3)
        print("点击Connection preferences")
        d(resourceId="android:id/title", text="Connection preferences").click()
        time.sleep(3)
        print("点击Bluetooth")
        d(resourceId="android:id/title", text="Bluetooth").click()
        time.sleep(3)
    def bluetooth_adnroid9():
        print("点击Bluetooth")
        d(resourceId="android:id/title", text="Bluetooth").click()
        time.sleep(3)

    def bluetooth_ON():
        time.sleep(2)
        print("点击bluetooth 按钮，关闭bluetooth")
        d(resourceId="com.android.settings:id/switch_widget", text="ON").click()
        time.sleep(5)
    def bluetooth_OFF():
        time.sleep(2)
        print("点击bluetooth 按钮，打开bluetooth")
        d(resourceId="com.android.settings:id/switch_widget", text="OFF").click()
        time.sleep(5)
    def bluetooth_scan():
        time.sleep(2)
        print("点击Pair new device ")
        d(resourceId="android:id/title", text="Pair new device").click()
        time.sleep(20)
    def back_click():
        d.press("back")
        print("按返回")
        time.sleep(3)
###Network & internet
##d(resourceId="android:id/title", text="Network & internet").click()
###Wi‑Fi
##d(resourceId="android:id/title", text="Wi‑Fi").click()
##
##d(resourceId="com.android.settings:id/switch_widget", text="ON").click()
##d(resourceId="com.android.settings:id/switch_widget", text="OFF").click()
##d.press("back")
##d.press("home")
def main():
    pass

if __name__ == '__main__':
    main()
